package edu.mse.camel.client.posterboard.ui.treeoutline;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.ContextMenuProvider;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IMenuManager;

import com.cea.papyrus.core.treeeditpart.TreeContextMenuProvider;

import edu.mse.camel.client.posterboard.ui.editor.PosterBoardModelManager;

public class PosterboardTreeContextMenuProvider extends ContextMenuProvider {

	private List<ContextMenuProvider> providers;
	private ActionRegistry registry;
	private PosterBoardModelManager pbModelManager;
	
	public PosterboardTreeContextMenuProvider(
			EditPartViewer viewer, ActionRegistry actionRegistry, PosterBoardModelManager mm) {
		super(viewer);
		this.providers = new ArrayList<ContextMenuProvider>();
		this.pbModelManager = mm;
		this.registry = actionRegistry;
		initializeProviders();
	}

	private void initializeProviders() {
		TreeContextMenuProvider papyrusProvider = 
			new TreeContextMenuProvider(getViewer(), registry, pbModelManager.getPapyrusModelManager());
		providers.add(papyrusProvider);
	}

	@Override
	public void buildContextMenu(IMenuManager menu) {
		for (ContextMenuProvider aProvider : providers) {
			aProvider.buildContextMenu(menu);
		}
	}
	
	public void addProvider(ContextMenuProvider provider) {
		this.providers.add(provider);
	}

}
